﻿using System;
using System.IO;

namespace DeleteOddLines
{
    class DeleteOddLines
    {
        static void RemoveOddLines(string path, string filename)
        {
            int number = 0;
            string line;

            using (StreamWriter writer = new StreamWriter(string.Format("{0}backup{1}", path, filename)))
            {
                using (StreamReader reader = new StreamReader(path + filename))
                {
                    while ((line = reader.ReadLine()) != null)
                    {
                        if (number % 2 == 1)
                        {
                            writer.WriteLine(line);
                        }
                        number++;
                    }
                }
            }
            File.Delete(path + filename);
            File.Move(string.Format("{0}backup{1}", path, filename), path + filename);
        }

        static void Main()
        {
            RemoveOddLines("..\\..\\", "Test.txt");
        }
    }
}
